export default {
    data() {
        return {
            ElasticMarkerStyles: [{
                icon: {
                    img: require("../../../assets/image/y-2.png"),
                    size: [30, 30],//可见区域的大小
                    ancher: [8, 16],//锚点
                    fitZoom: 14,//最合适的级别
                    scaleFactor: 2,//地图放大一级的缩放比例系数
                    maxScale: 1.4,//最大放大比例
                    minScale: 0.8//最小放大比例,
                    , imageSize: [30, 30]
                }
            }],
            ElasticMarkerMassmarkStyles: [{
                icon: {
                    img: require("../../../assets/image/a.png"),
                    size: [20, 20],//可见区域的大小
                    ancher: [8, 16],//锚点
                    fitZoom: 14,//最合适的级别
                    scaleFactor: 2,//地图放大一级的缩放比例系数
                    maxScale: 1.4,//最大放大比例
                    minScale: 0.8//最小放大比例,
                    , imageSize: [20, 20]
                }
            }],
            ElasticMarkerZoomStyleMapping: {
                1: 0,
                2: 0,
                3: 0,
                4: 0,
                5: 0,
                6: 0,
                7: 0,
                8: 0,
                9: 0,
                10: 0,
                11: 0,
                12: 0,
                13: 0,
                14: 0,
                15: 0,
                16: 0,
                17: 0,
                18: 0,
                19: 0,
                20: 0
            },
            ElasticMarkerZooms: [1, 20],
            ElasticMarkerList: [],
            massmarkList: [],
        }
    },
    methods: {
        /**
         * 创建灵活点
         * @param position
         * @param content
         */
        createElasticMarker(position, content = {}) {

            let emark = new AMap.ElasticMarker({
                styles: this.ElasticMarkerStyles,
                zoomStyleMapping: this.ElasticMarkerZoomStyleMapping,
                zooms: this.ElasticMarkerZooms,
                position: position,
                zIndex: 200,
                bubble: true
            })
            let that = this;
            emark.on("mouseover", e => {
                let infoWindow = that.addInfoWindow("监测人员", content, "monitor");
                infoWindow.open(that.map, e.lnglat);
            });
            emark.on("mouseout", () => {
                that.closeInfoWindow()
            });
            this.ElasticMarkerList.push(emark);
            this.map.add(emark);
        },
        createElasticMassmark(position, content = {}) {
            let emark = new AMap.ElasticMarker({
                styles: this.ElasticMarkerMassmarkStyles,
                zoomStyleMapping: this.ElasticMarkerZoomStyleMapping,
                zooms: this.ElasticMarkerZooms,
                position: position,
                zIndex: 80,
                bubble: true
            })
            let that = this;
            emark.on("mouseover", e => {
                let infoWindow = that.addInfoWindow("黑广播", content, "broad");
                infoWindow.open(that.map, e.lnglat);
            });
            emark.on("mouseout", () => {
                that.closeInfoWindow()
            });
            this.massmarkList.push(emark);
            this.map.add(emark);
        },
        /**
         * 清除灵活点
         */
        cleatElasticMarker() {
            this.map.remove(this.ElasticMarkerList);
            this.ElasticMarkerList = [];
        },
        /**
         * 清除灵活点
         */
        cleatElasticMarkerMass() {
            this.map.remove(this.massmarkList);
            this.massmarkList = [];
        }
    }
}